package monopoly.View;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JOptionPane;

import monopoly.Model.Figur;
import monopoly.Model.Strasse;

public class ButtonActionListener implements ActionListener {
    private KaufenDialog  dialog = null;
    int result;
    private Strasse strasse;
    private Figur figur;
    

   public void updateData(Strasse str,Figur figur, KaufenDialog  dialog ){
        this.strasse=str;
        this.dialog= dialog;
        this.figur= figur;
        
    }
    public ButtonActionListener(){

    }

    public void actionPerformed(ActionEvent e) {
        String cmd = e.getActionCommand();
          
   
                if (cmd.equals("Ja")) {
                    if ( true == figur.kaufen( this.strasse) ) {
                        JOptionPane.showMessageDialog(null, "Sie haben die Strasse gekauft! ", "Strasse Kaufen",JOptionPane.WARNING_MESSAGE);
                    } else {
                        JOptionPane.showMessageDialog(null,"Sie haben leder nicht genug Geld! ", "Strasse Kaufen",JOptionPane.WARNING_MESSAGE);
                    }
                }
                if (cmd.equals("Nein")) {
                  
                }
                this.dialog.setVisible( false );
               
        }
}


